home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / pckey.exe / PCKEYD.CPP < prev   
C/C++ Source or Header  |  1991-08-23  |  2KB  |  105 lines

  1. /*
  2.  
  3.     pckeyd.cpp
  4.     8-23-91
  5.     pckey demo
  6.  
  7.     Copyright 1991
  8.     John W. Small
  9.     All rights reserved
  10.     Use freely but acknowledge authorship and copyright.
  11.  
  12.     PSW / Power SoftWare
  13.     P.O. Box 10072
  14.     McLean, Virginia 22102 8072 USA
  15.  
  16.     John Small
  17.     Voice: (703) 759-3838
  18.     CIS: 73757,2233
  19.  
  20. */
  21.  
  22. #include <stdio.h>
  23. #include <pckey.hpp>
  24.  
  25.  
  26. main()
  27. {
  28.     int ch;
  29.     unsigned lastShift = PCK.shift();
  30.  
  31.     puts("\n\nPress ESC to continue, any other key"
  32.         " to view getch(), ascii(), and scan() ...");
  33.     while (!PCK.kbhit())
  34.         if (PCK.shift() != lastShift)  {
  35.             lastShift = PCK.shift();
  36.             printf("\n PCK.shift(): %04x",
  37.                 PCK.shift());
  38.         }
  39.     while ((ch = PCK.getch()) != ESC)  {
  40.         printf("\n PCK.getch(): %1c%1c     "
  41.             "PCK.ascii():  %3d   "
  42.             "PCK.scan(): %3d",
  43.             (ch <= 26 && ch)? '^':' ',
  44.             (ch <= 26 && ch)? ch+'@':ch,
  45.             PCK.ascii(), PCK.scan());
  46.         while (!PCK.kbhit())
  47.             if (PCK.shift() != lastShift)  {
  48.                 lastShift = PCK.shift();
  49.                 printf("\n PCK.shift(): "
  50.                     "%04x",PCK.shift());
  51.             }
  52.     }
  53.  
  54.     puts("\n\nPress ESC to continue, any other key"
  55.         " to view getkey(), ascii(), and scan() ...");
  56.     while (!PCK.kbhit())
  57.         if (PCK.shift() != lastShift)  {
  58.             lastShift = PCK.shift();
  59.             printf("\n PCK.shift(): %04x",
  60.                 PCK.shift());
  61.         }
  62.     while ((ch = PCK.getkey()) != ESC)  {
  63.         if (ch >= 0)
  64.             printf("\n PCK.getkey(): %1c%1c     "
  65.                 "PCK.ascii():  %3d   "
  66.                 "PCK.scan(): %3d",
  67.                 (ch <= 26 && ch)? '^':' ',
  68.                 (ch <= 26 && ch)? ch+'@':ch,
  69.                 PCK.ascii(), PCK.scan());
  70.         else
  71.             printf("\n PCK.getkey(): %4d   "
  72.                 "PCK.ascii():  %3d   "
  73.                 "PCK.scan(): %3d",ch,
  74.                 PCK.ascii(), PCK.scan());
  75.  
  76.         while (!PCK.kbhit())
  77.             if (PCK.shift() != lastShift)  {
  78.                 lastShift = PCK.shift();
  79.                 printf("\n PCK.shift(): "
  80.                     "%04x",PCK.shift());
  81.             }
  82.     }
  83.     if (PCK.enhanced())  {
  84.         puts("\n\nNow for the typematic test.  "
  85.             "Hold down any key to view the ");
  86.         puts("standard rates.  ESC for high "
  87.             "speed.\n");
  88.         PCK.setTypeMatic();
  89.         ch = PCK.getch();
  90.         while (ch != ESC)
  91.             putchar(ch = PCK.getch());
  92.         puts("\n\nNow for highest speed hold "
  93.             "down any key.  ESC to quit.\n");
  94.         PCK.fastTypeMatic();
  95.         ch = PCK.getch();
  96.         while (ch != ESC)
  97.             putchar(ch = PCK.getch());
  98.     }
  99.     else
  100.         puts("\n\nKey board is not enhanced.");
  101.     PCK.fastTypeMaticOnExit();
  102.     return 0;
  103.  
  104. }
  105.